"""
Copyright (c) 2022 Guangdong University of Technology
PhotLab is licensed under [Open Source License].
You can use this software according to the terms and conditions of the [Open Source License].
You may obtain a copy of [Open Source License] at: [https://open.source.license/]

THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.

See the [Open Source License] for more details.

Author: Meng Xiang, Sailan Yan
Created: 2023/8/19
Supported by: National Key Research and Development Program of China
"""


import numpy as np


def PBC(input_1, input_2):
    """偏振合束器

    Args:
        input_1: 信号1
        input_2: 信号2

    Returns:
        output：偏振合束后光信号

    """

    # Input_X_I = np.expand_dims(np.real(input_1), axis=1)
    # Input_X_Q = np.expand_dims(np.imag(input_1), axis=1)
    # Input_Y_I = np.expand_dims(np.real(input_2), axis=1)
    # Input_Y_Q = np.expand_dims(np.imag(input_2), axis=1)
    Input_X_I = np.real(input_1)
    Input_X_Q = np.imag(input_1)
    Input_Y_I = np.real(input_2)
    Input_Y_Q = np.imag(input_2)


    epsilon_x = 1
    epsilon_y = 0
    sigma_x = 1
    sigma_y = 0
    output_XY_I = epsilon_x * Input_X_I + sigma_y * Input_Y_I
    output_XY_Q = sigma_x * Input_X_Q + epsilon_y * Input_Y_Q
    output = output_XY_I + 1j * output_XY_Q
    return output[:, 0]
